package com.example.algorithmdemo.string;

public class LLString {
    /**
     * 字符串的反转
     * @param str
     * @return
     */
    public static String reverseStr(String str){
        StringBuilder stringBuilder = new StringBuilder(str);
        int left = 0;
        int right = str.length() - 1;
        while (left < right){
            Character temp = stringBuilder.charAt(left);
            stringBuilder.setCharAt(left++,stringBuilder.charAt(right));
            stringBuilder.setCharAt(right--,temp);
        }
        return stringBuilder.toString();
    }
}
